package com.nthinkers.sabq.activities;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

import com.nthinkers.sabq.R;

public class AboutusActivity extends BaseActivity {
	ImageButton btnSabqWebsite;
	ImageButton imbContactUs;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.screen_aboutus);
		setupWidgets();

	}

	private void setupWidgets() {
		btnSabqWebsite = (ImageButton) findViewById(R.id.aboutus_btn_sabq_website);
		imbContactUs = (ImageButton) findViewById(R.id.aboutus_imb_contactus);
		btnSabqWebsite.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent viewIntent = new Intent("android.intent.action.VIEW",
						Uri.parse("http://"
								+ getString(R.string.aboutus_sabq_website)));
				startActivity(viewIntent);

			}

		});

		imbContactUs.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				sendEmail(getString(R.string.aboutus_contactusaddress),
						getString(R.string.aboutus_contactus_subject),
						getString(R.string.aboutus_contactus_text));

			}
		});
	}

	private void sendEmail(String address, String subject, String text) {
		final Intent emailIntent = new Intent(
				android.content.Intent.ACTION_SEND);

		emailIntent.setType("plain/text");

		emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
				new String[] { address });

		emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);

		emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);

		AboutusActivity.this.startActivity(Intent.createChooser(emailIntent,
				"Send mail..."));

	}

}
